E) STL::priority_queue

#include <iostream>
#include <queue>
#include <functional>
#include <string>
using namespace std;
struct User{
int id, age;
bool adult;
string name;
static int id_num;
User(string _name, int _age, bool _adult=true): name(_name), age(_age), adult(_adult){
id=id_num++;
}
bool operator<(const User other) const {
return this->id>other.id; //
}
};
int User::id_num=1;
int main(void){
std::priority_queue<User> Users;
Users.push(User("one", 10, false));
Users.push(User("two", 20, true));
Users.push(User("three", 30, true));
Users.push(User("four", 35, true));
Users.push(User("five", 19, false));
Users.push(User("six", 18, false));
Users.push(User("seven", 29, true));
Users.push(User("eight", 35, true));
while(!Users.empty()){
User user=Users.top();
Users.pop();
cout<<user.id<<" : "<<user.name<<endl;
}
return 0;
}